﻿using System;
using System.Collections.Generic;
using T.FAS.Runtime.Metadata.Entity.DataModel;
using T.FAS.Runtime.Metadata.Entity;

namespace T.FAS.Runtime.DataAccess.SQLDom
{
    /// <summary>
    /// sql执行控制上下文类
    /// </summary>
    public class SqlExecuteControlContext: MaskControlContext
    {
        /// <summary>
        /// 额外参数参数存储字典
        /// </summary>
        private readonly Dictionary<string, object> _extParam = new Dictionary<string, object>();

        /// <summary>
        /// 元数据信息
        /// </summary>
        public string MetaDataType { set; get; }

        /// <summary>
        /// 元数据信息
        /// </summary>
        public IMetaDataContent MetaInfo { get; set; }

        /// <summary>
        /// 超时时间
        /// </summary>
        public int Timeout { get; set; } = 0;

        /// <summary>
        /// 是否校验时间戳
        /// </summary>
        public bool IsCheckTimestamp { set; get; } = true;

        /// <summary>
        /// 时间戳记录
        /// </summary>
        public string Timestamp { get; set; }
        
        /// <summary>
        /// 只读列
        /// </summary>
        public List<string> ReadonlyFields { get; set; }

        /// <summary>
        /// 国际化模式
        /// </summary>
        public InternationalMode InternationalMode { get; set; } = InternationalMode.All;

        /// <summary>
        /// 指定的国际化语言
        /// </summary>
        public List<string> SpecifiedLanguages { get; set; }

        #region Funcs
        /// <summary>
        /// 存储额外参数
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void SetExtParam(string key, object value)
        {
            _extParam[key] = value;
        }

        /// <summary>
        /// 获取额外参数
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public object GetExtParam(string key)
        {
            if (_extParam.TryGetValue(key, out object val))
            {
                return val;
            }
            return null;
        }

        #endregion
    }
}